﻿// See https://aka.ms/new-console-template for more information
//使用迭代器
foreach(var item in GetInts())
{
    Console.WriteLine("外部遍历了：{0}",item);
}



//定义一个迭代器
IEnumerable<int> GetInts()
{
    for(int i = 0; i < 5; i++)
    {
        Console.WriteLine("内部遍历了:{0}",i);
        yield return i;
    }
}


Console.WriteLine("Hello, World!");
